package cn.com.infinova;

import cn.hutool.core.lang.SimpleCache;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            while (true) {
                synchronized (Test.class) {
                    Test.cache.get(String.class, () -> "test");
                    Test.cache.get(Double.class, () -> "test");
                    Test.cache.get(Integer.class, () -> "test");
                    System.out.println("test4");
                }
            }
        }, "test4");
        Thread thread1 = new Thread(() -> {
            while (true) {
                synchronized (Test.class) {
                    Test.cache.get(String.class, () -> "test");
                    Test.cache.get(Double.class, () -> "test");
                    Test.cache.get(Integer.class, () -> "test");
                    System.out.println("test3");
                }
            }
        }, "test3");
        Thread thread2 = new Thread(() -> {
            while (true) {
                synchronized (Test.class) {
                    Test.cache.get(String.class, () -> "test");
                    Test.cache.get(Double.class, () -> "test");
                    Test.cache.get(Integer.class, () -> "test");
                    System.out.println("test2");
                }
            }
        }, "test2");
        Thread thread3 = new Thread(() -> {
            while (true) {
                synchronized (String.class) {
                    Test.cache.get(String.class, () -> "test");
                    Test.cache.get(Double.class, () -> "test");
                    Test.cache.get(Integer.class, () -> "test");
                    System.out.println("test1");
                }
            }
        }, "test1");
        thread.start();
        thread1.start();
        thread2.start();
        thread3.start();
    }

    public static class Test {
        private final static SimpleCache<Class<?>, String> cache = new SimpleCache<>();
    }
}
